{include inc/top.m.html}
<script>
    var api = frameElement.api, W = api.opener;
    $(function(){

        api.size(450 , 'auto');
        var v = $('.{$cb}' , api.get('vwin').document).val();
        if(v != ''){
            $('.tag-btn').each(function(){
                if(v.indexOf($(this).text()) >= 0){
                    $(this).addClass('tag-selected');
                }
            });
            $('#desc_msg').text(v);
        }
        $('.tag-btn').bind('click' , function(){
            if($(this).hasClass('tag-selected')){
                $('#desc_msg').text($('#desc_msg').text().replace(new RegExp("\,?" + $(this).text() , 'ig') , ''));
                $(this).removeClass('tag-selected');
            }else{
                if($('#desc_msg').text() == ''){
                    $('#desc_msg').text($(this).text());
                }else{
                    $('#desc_msg').text($('#desc_msg').text() + ',' + $(this).text());
                }
                $(this).addClass('tag-selected');
            }
            if($('#desc_msg').text().substr(0,1) == ','){
                $('#desc_msg').text($('#desc_msg').text().substr(1));
            }
        });

        $('#act_sbtn').bind('click' , function(){
            if($('#desc_msg').text() != ''){
                api.get('vwin').{$cb}($('#desc_msg').text());
            }
            api.close();
        });
    });
</script>
<div class="index-main" style="width:100%;margin:0;padding:0;">
    <table style="width:100%">
        <tr>
            <td class="td left" >
                <div>
                {for i in range(65 , 91)}
                    <a href="{url:('admin@tag-get-ctype-%d-code-%s-cb-%s' , $ctype , chr($i) , $cb)}" class="filter-btn {:(ord($code) == $i ? ' active' :'')}">{:chr($i)}</a>&nbsp;
                {/for}
                </div>
                <div style="height:240px;">
                {foreach $tags $k $v}
                    <a href="javascript:void(0);" class="tag-btn">{$v['name']}</a>
                {/foreach}
                </div>
            </td>
        </tr>
        <tr>
            <td class="td left">
                <input type="button" id="act_sbtn" class="button" value="确定"/> &nbsp;&nbsp;
                <span id="desc_msg" class="error-tips"></span>
            </td>
        </tr>

    </table>
    <div class="clear"></div>
</div>
{include inc/bottom.m.html}